local skill = fk.CreateSkill {
  name = "#ling__kylin_bow_skill",
  attached_equip = "ling__kylin_bow",
}

Fk:loadTranslationTable{
  ["#ling__kylin_bow_skill"] = "麒麟弓",
}

skill:addEffect(fk.DamageCaused, {
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(skill.name) and
      data.card and data.card.trueName == "slash" and not data.chain and
      (#data.to:getEquipments(Card.SubtypeDefensiveRide) > 0 or #data.to:getEquipments(Card.SubtypeOffensiveRide) > 0)
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    room:broadcastPlaySound("./packages/standard_cards/audio/card/kylin_bow")
    room:setEmotion(player, "./packages/standard_cards/image/anim/kylin_bow")
    local to = data.to
    local ride_tab = table.connect(data.to:getEquipments(Card.SubtypeDefensiveRide), data.to:getEquipments(Card.SubtypeOffensiveRide))
    if #ride_tab == 0 then return end
    local id = room:askToChooseCard(player, {
      target = to,
      flag = { card_data = {{ "equip_horse", ride_tab }} },
      skill_name = skill.name,
    })
    room:throwCard(id, skill.name, to, player)
  end,
})

return skill
